package com.uchedao.seller.module;

import com.google.gson.Gson;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
 * 车型信息
 * 
 * @author "叶晋"
 * 
 */
public class CarTypeInfo implements Cloneable {
	// 二维码ID固定头
	private static final String CHECKID_HEAD = "http://m.uchedao.com/checkid/";

	@Expose
	@SerializedName("import_type")
	public String import_type;// 国产/进口

	@Expose
	@SerializedName("car_engines")
	public String car_engines;// 排量

	@Expose
	@SerializedName("emission_standards")
	public String emission_standards;// 排放标准

	@Expose
	@SerializedName("driver_number")
	public String driver_number;// 发动机号

	@Expose
	@SerializedName("trans_type")
	public String trans_type;// 变速形式

	@Expose
	@SerializedName("kilometer")
	public String kilometer;// 表显里程

	@Expose
	@SerializedName("drive_type")
	public String drive_type;// 驱动方式

	@Expose
	@SerializedName("checkid")
	private String checkid;// 二维码ID

	/**
	 * 得到二维码ID
	 * 
	 * @return
	 */
	public String getCheckid() {
		if (checkid != null && checkid.toLowerCase().startsWith(CHECKID_HEAD))
			return checkid.substring(CHECKID_HEAD.length());
		return checkid;
	}

	/**
	 * 设置二维码ID
	 * 
	 * @param checkid
	 */
	public void setCheckid(String checkid) {
		if (checkid == null)
			this.checkid = "";
		else if (checkid.toLowerCase().startsWith(CHECKID_HEAD))
			this.checkid = checkid;
		else
			this.checkid = CHECKID_HEAD + checkid;
	}

	@Override
	public CarTypeInfo clone() throws CloneNotSupportedException {
		return (CarTypeInfo) super.clone();
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null || getClass() != obj.getClass()) {
			return false;
		}
		CarTypeInfo carTypeInfo = getClass().cast(obj);
		return carTypeInfo.toString().equals(toString());
	}

	public String toString() {
		return new Gson().toJson(this);
	}
}
